<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>狼族少年、血狼</title><meta name="author" content="狼族少年、血狼"><meta name="copyright" content="狼族少年、血狼"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta property="og:type" content="website">
<meta property="og:title" content="狼族少年、血狼">
<meta property="og:url" content="https://geekwolfman.github.io/index.html">
<meta property="og:site_name" content="狼族少年、血狼">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/config/avatar/avatar.png">
<meta property="article:author" content="狼族少年、血狼">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/config/avatar/avatar.png"><link rel="shortcut icon" href="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/config/avatar/avatar.png"><link rel="canonical" href="https://geekwolfman.github.io/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/db.json","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '狼族少年、血狼',
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2023-06-08 14:15:24'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pace-js/themes/blue/pace-theme-minimal.min.css"/><script src="https://cdn.jsdelivr.net/npm/pace-js/pace.min.js"></script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/config/avatar/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">57</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">14</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 画廊</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-paper-plane"></i><span> 关于</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page" id="page-header" style="background-image: url('https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/config/pages/01index.png')"><nav id="nav"><span id="blog-info"><a href="/" title="狼族少年、血狼"><span class="site-name">狼族少年、血狼</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 画廊</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-paper-plane"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">狼族少年、血狼</h1><div id="site-subtitle"><span id="subtitle"></span></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left"><a href="/2023/03/23/hexo%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%E2%80%94%E2%80%94%E4%BB%8E%E4%BB%98%E8%B4%B9%E5%88%B0%E7%99%BD%E5%AB%96%E7%9A%84%E6%9E%81%E8%87%B4%E4%BD%93%E9%AA%8C.html" title="hexo博客搭建——从付费到白嫖的极致体验"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/hexo%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%E2%80%94%E2%80%94%E4%BB%8E%E4%BB%98%E8%B4%B9%E5%88%B0%E7%99%BD%E5%AB%96%E7%9A%84%E6%9E%81%E8%87%B4%E4%BD%93%E9%AA%8C/01cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="hexo博客搭建——从付费到白嫖的极致体验"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/03/23/hexo%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%E2%80%94%E2%80%94%E4%BB%8E%E4%BB%98%E8%B4%B9%E5%88%B0%E7%99%BD%E5%AB%96%E7%9A%84%E6%9E%81%E8%87%B4%E4%BD%93%E9%AA%8C.html" title="hexo博客搭建——从付费到白嫖的极致体验">hexo博客搭建——从付费到白嫖的极致体验</a><div class="article-meta-wrap"><span class="article-meta"><i class="fas fa-thumbtack sticky"></i><span class="sticky">置顶</span><span class="article-meta-separator">|</span></span><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-03-23T08:22:30.000Z" title="发表于 2023-03-23 16:22:30">2023-03-23</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-05-06T13:25:37.738Z" title="更新于 2023-05-06 21:25:37">2023-05-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%BD%91%E7%AB%99%E6%90%AD%E5%BB%BA/">网站搭建</a></span></div><div class="content">由于自建的博客网站域名和服务器即将到期，本人无力续费，因此选择hexo框架重建网站，主题选用轻量美观的hexo-theme-butterfly。这里记录一下搭建过程，主要感受一下从付费到白嫖的极致体验。

更新一下，由于托管图片加载速度较慢影响体验，后续更改为阿里云oss存储，有少量成本

博客搭建hexo框架
官方文档介绍得非常详细，从安装、部署到基本指令以及自定义配置等，请仔细阅读。
butterfly主题
这里我们贴出butterfly主题的官方使用文档，非常详细，建议每个文档仔细阅读：

Butterfly 安装文档(一) 快速开始
Butterfly 安装文档(二) 主题页面
Butterfly 安装文档(三) 主题配置-1
Butterfly 安装文档(四) 主题配置-2
Butterfly 进阶教程

常用命令这里整理一下常用命令，完整命令移步到 hexo框架文档 查看

new

1hexo new [layout] &lt;title&gt;

新建一篇文章。如果没有设置 layout 的话，默认使用 _config.yml 中的 default_layout 参数代 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/05/06/%E4%B8%80%E6%96%87%E8%AF%A6%E8%A7%A3Optional.html" title="一文详解Optional"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E4%B8%80%E6%96%87%E8%AF%A6%E8%A7%A3Optional/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="一文详解Optional"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/05/06/%E4%B8%80%E6%96%87%E8%AF%A6%E8%A7%A3Optional.html" title="一文详解Optional">一文详解Optional</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-05-06T14:57:00.000Z" title="发表于 2023-05-06 22:57:00">2023-05-06</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-05-06T15:02:12.242Z" title="更新于 2023-05-06 23:02:12">2023-05-06</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/java/">java</a></span></div><div class="content">简介当我们需要使用某个对象的属性或方法时，如果该对象为 null，则会抛出空指针异常。为了避免这种异常的发生，我们通常需要在代码中添加大量的 if-else 判断来检查对象是否为 null。这样的代码不仅繁琐，而且不易于阅读和维护。
Optional 类提供了一种更好的方式来处理 null 值。使用 Optional 类，可以将对象的可能存在或不存在的状态封装成一个容器对象，可以避免直接操作对象时出现空指针异常，同时还能让代码更加简洁和易于阅读。
Brian Goetz （Java语言设计架构师）对Optional设计意图的原话如下：

Optional is intended to provide a limited mechanism for library method return types where there needed to be a clear way to represent “no result,” and using null for such was overwhelmingly likely to cause errors.

这句话突出了三个点：

O ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/05/02/%E4%B8%80%E6%96%87%E8%AF%A6%E8%A7%A3Stream%E6%B5%81.html" title="一文详解Stream流"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E4%B8%80%E6%96%87%E8%AF%A6%E8%A7%A3Stream%E6%B5%81/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="一文详解Stream流"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/05/02/%E4%B8%80%E6%96%87%E8%AF%A6%E8%A7%A3Stream%E6%B5%81.html" title="一文详解Stream流">一文详解Stream流</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-05-02T15:37:56.000Z" title="发表于 2023-05-02 23:37:56">2023-05-02</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-05-02T15:48:56.200Z" title="更新于 2023-05-02 23:48:56">2023-05-02</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/java/">java</a></span></div><div class="content">简介Stream支持元素流功能性操作的类，例如集合上的map-reduce转换。 例如：
1int sum = widgets.stream().filter(b -&gt; b.getColor() == RED).mapToInt(b -&gt; b.getWeight()).sum();  

这里我们使用widgets Collection&lt;Widget&gt;作为流的源，然后在流上执行filter-map-reduce以获得红色小部件的权重之和。（求和是一个的例子reduction操作）。
这个包中引入的关键抽象是流。流与集合有以下几种不同：

没有存储。 流不是存储元素的数据结构;  相反，它通过计算操作的流水线传送诸如数据结构，数组，生成器功能或I&#x2F;O通道的源的元件。
功能性质。 流上的操作产生结果，但不会修改其来源。  例如，过滤从Stream获得的Stream会生成旧的Stream不需要的元素，而不是从源集合中删除元素。
懒惰执行。 许多流操作（如过滤，映射或重复删除）可以懒惰地实现，从而暴露优化的机会。  例如，”找到具有三个连续元音的第一个Stri ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/04/22/%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E8%AE%A1%E7%AE%97%E5%99%A8.html" title="实现一个计算器"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E8%AE%A1%E7%AE%97%E5%99%A8/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="实现一个计算器"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/22/%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E8%AE%A1%E7%AE%97%E5%99%A8.html" title="实现一个计算器">实现一个计算器</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-22T12:34:00.000Z" title="发表于 2023-04-22 20:34:00">2023-04-22</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-22T12:37:18.221Z" title="更新于 2023-04-22 20:37:18">2023-04-22</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述实现一个计算器支持+、-、*、&#x2F;、（、)等，需要支持括号嵌套。
示例 1：
12输入：s = 1*2-3*5*8/4+3输出：-25

示例 2：
12输入：s = 12*4-25+6/(2+(2-1)*2-1)-4*3输出：13

示例 3：
12输入：s = 12*4-(25+6/(2+(2-1)*2-1)-4*3)输出：33

示例 4：
12输入：s = 12*4/2-(25+6/(2+(2-1)*2-1)-4*3)输出：9

我的解法思路此题与leetcode题库中的 面试题 16.26. 计算器 非常类似，不同的是此题需要处理嵌套的括号。一个比较普遍的思路就是首先处理括号，将整个表达式转换为没有括号的算式，再进行计算。
我们使用栈记录已经遍历的字符，当遇到第一个右括号时，说明是第一个嵌套最深的括号，我们依次弹出元素，直到遇到与其匹配的左括号，计算后，再次压入栈中。重复以上步骤，便可处理掉所有括号，接下来再计算算式。
代码123456789101112131415161718192021222324252627282930313233343536373839 ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/04/19/%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2-II.html" title="零钱兑换 II"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2%20II/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="零钱兑换 II"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/19/%E9%9B%B6%E9%92%B1%E5%85%91%E6%8D%A2-II.html" title="零钱兑换 II">零钱兑换 II</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-19T15:31:42.000Z" title="发表于 2023-04-19 23:31:42">2023-04-19</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-19T15:33:40.722Z" title="更新于 2023-04-19 23:33:40">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述
题目链接：518. 零钱兑换 II

给你一个整数数组 coins 表示不同面额的硬币，另给一个整数 amount 表示总金额。
请你计算并返回可以凑成总金额的硬币组合数。如果任何硬币组合都无法凑出总金额，返回 0 。
假设每一种面额的硬币有无限个。
题目数据保证结果符合 32 位带符号整数。
示例1：
1234567输入：amount = 5, coins = [1, 2, 5]输出：4解释：有四种方式可以凑成总金额：5=55=2+2+15=2+1+1+15=1+1+1+1+1

示例2：
123输入：amount = 3, coins = [2]输出：0解释：只用面额 2 的硬币不能凑成总金额 3 。

示例2：
12输入：amount = 10, coins = [10] 输出：1

提示：

1 &lt;= coins.length &lt;= 300
1 &lt;= coins[i] &lt;= 5000
coins 中的所有值 互不相同
0 &lt;= amount &lt;= 5000

我的题解方法一：01背包思想思路设dp[i][j]为在前i个银币中凑成金额 ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/04/19/%E4%B8%80%E5%92%8C%E9%9B%B6.html" title="一和零"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E4%B8%80%E5%92%8C%E9%9B%B6/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="一和零"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/19/%E4%B8%80%E5%92%8C%E9%9B%B6.html" title="一和零">一和零</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-19T15:28:37.000Z" title="发表于 2023-04-19 23:28:37">2023-04-19</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-19T15:30:34.440Z" title="更新于 2023-04-19 23:30:34">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述
题目链接：474. 一和零

给你一个二进制字符串数组 strs 和两个整数 m 和 n 。
请你找出并返回 strs 的最大子集的长度，该子集中 最多 有 m 个 0 和 n 个 1 。
如果 x 的所有元素也是 y 的元素，集合 x 是集合 y 的 子集 。
示例1：
1234输入：strs = [&quot;10&quot;, &quot;0001&quot;, &quot;111001&quot;, &quot;1&quot;, &quot;0&quot;], m = 5, n = 3输出：4解释：最多有 5 个 0 和 3 个 1 的最大子集是 &#123;&quot;10&quot;,&quot;0001&quot;,&quot;1&quot;,&quot;0&quot;&#125; ，因此答案是 4 。其他满足题意但较小的子集包括 &#123;&quot;0001&quot;,&quot;1&quot;&#125; 和 &#123;&quot;10&quot;,&quot;1&quot;,&quot;0&quot;&#125; 。&#123;&quot;1110 ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/04/19/%E7%9B%AE%E6%A0%87%E5%92%8C.html" title="目标和"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E7%9B%AE%E6%A0%87%E5%92%8C/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="目标和"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/19/%E7%9B%AE%E6%A0%87%E5%92%8C.html" title="目标和">目标和</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-19T15:26:21.000Z" title="发表于 2023-04-19 23:26:21">2023-04-19</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-19T15:28:12.097Z" title="更新于 2023-04-19 23:28:12">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述
题目链接：494. 目标和

给你一个整数数组 nums 和一个整数 target 。
向数组中的每个整数前添加 &#39;+&#39; 或 &#39;-&#39; ，然后串联起所有整数，可以构造一个 表达式 ：

例如，nums = [2, 1] ，可以在 2 之前添加 &#39;+&#39; ，在 1 之前添加 &#39;-&#39; ，然后串联起来得到表达式 &quot;+2-1&quot; 。

返回可以通过上述方法构造的、运算结果等于 target 的不同 表达式 的数目。
示例1：
12345678输入：nums = [1,1,1,1,1], target = 3输出：5解释：一共有 5 种方法让最终目标和为 3 。-1 + 1 + 1 + 1 + 1 = 3+1 - 1 + 1 + 1 + 1 = 3+1 + 1 - 1 + 1 + 1 = 3+1 + 1 + 1 - 1 + 1 = 3+1 + 1 + 1 + 1 - 1 = 3

示例2：
12输入：nums = [1], target = 1输出：1

提示：

1 &lt;= nums.length &l ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/04/19/%E6%9C%80%E5%90%8E%E4%B8%80%E5%9D%97%E7%9F%B3%E5%A4%B4%E7%9A%84%E9%87%8D%E9%87%8F-II.html" title="最后一块石头的重量 II"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E6%9C%80%E5%90%8E%E4%B8%80%E5%9D%97%E7%9F%B3%E5%A4%B4%E7%9A%84%E9%87%8D%E9%87%8F%20II/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="最后一块石头的重量 II"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/19/%E6%9C%80%E5%90%8E%E4%B8%80%E5%9D%97%E7%9F%B3%E5%A4%B4%E7%9A%84%E9%87%8D%E9%87%8F-II.html" title="最后一块石头的重量 II">最后一块石头的重量 II</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-19T15:24:11.000Z" title="发表于 2023-04-19 23:24:11">2023-04-19</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-19T15:26:07.576Z" title="更新于 2023-04-19 23:26:07">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述
题目链接：1049. 最后一块石头的重量 II

有一堆石头，用整数数组 stones 表示。其中 stones[i] 表示第 i 块石头的重量。
每一回合，从中选出任意两块石头，然后将它们一起粉碎。假设石头的重量分别为 x 和 y，且 x &lt;= y。那么粉碎的可能结果如下：

如果 x == y，那么两块石头都会被完全粉碎；
如果 x != y，那么重量为 x 的石头将会完全粉碎，而重量为 y 的石头新重量为 y-x。

最后，最多只会剩下一块 石头。返回此石头 最小的可能重量 。如果没有石头剩下，就返回 0。
示例1：
1234567输入：stones = [2,7,4,1,8,1]输出：1解释：组合 2 和 4，得到 2，所以数组转化为 [2,7,1,8,1]，组合 7 和 8，得到 1，所以数组转化为 [2,1,1,1]，组合 2 和 1，得到 1，所以数组转化为 [1,1,1]，组合 1 和 1，得到 0，所以数组转化为 [1]，这就是最优值。

示例2：
12输入：stones = [31,26,33,21,40]输出：5

提示：

1 &lt;= sto ...</div></div></div><div class="recent-post-item"><div class="post_cover left"><a href="/2023/04/19/%E5%88%86%E5%89%B2%E7%AD%89%E5%92%8C%E5%AD%90%E9%9B%86.html" title="分割等和子集"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E5%88%86%E5%89%B2%E7%AD%89%E5%92%8C%E5%AD%90%E9%9B%86/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="分割等和子集"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/19/%E5%88%86%E5%89%B2%E7%AD%89%E5%92%8C%E5%AD%90%E9%9B%86.html" title="分割等和子集">分割等和子集</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-19T15:21:36.000Z" title="发表于 2023-04-19 23:21:36">2023-04-19</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-19T15:23:53.426Z" title="更新于 2023-04-19 23:23:53">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述
题目链接：416. 分割等和子集

给你一个 只包含正整数 的 非空 数组 nums 。请你判断是否可以将这个数组分割成两个子集，使得两个子集的元素和相等。
示例1：
123输入：nums = [1,5,11,5]输出：true解释：数组可以分割成 [1, 5, 5] 和 [11] 。

示例2：
123输入：nums = [1,2,3,5]输出：false解释：数组不能分割成两个元素和相等的子集。

提示：

1 &lt;= nums.length &lt;= 200
1 &lt;= nums[i] &lt;= 100

我的题解方法一：动态规划思路求出当前数组和，若为奇数则不可分成两个相等的子集，若和为偶数，则需要子集的和必须为和&#x2F;2，也就是可以转化为从数组中选择若干数字，装入容量为和&#x2F;2的背包中，是否能装满，因此转化为01背包问题。
代码1234567891011121314151617181920class Solution &#123;    public boolean canPartition(int[] nums) &#123;       ...</div></div></div><div class="recent-post-item"><div class="post_cover right"><a href="/2023/04/19/%E4%B8%8D%E5%90%8C%E7%9A%84%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.html" title="不同的二叉搜索树"><img class="post-bg" src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/articles/%E4%B8%8D%E5%90%8C%E7%9A%84%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91/00cover.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="不同的二叉搜索树"></a></div><div class="recent-post-info"><a class="article-title" href="/2023/04/19/%E4%B8%8D%E5%90%8C%E7%9A%84%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91.html" title="不同的二叉搜索树">不同的二叉搜索树</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-04-19T15:18:43.000Z" title="发表于 2023-04-19 23:18:43">2023-04-19</time><span class="article-meta-separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-04-19T15:21:23.056Z" title="更新于 2023-04-19 23:21:23">2023-04-19</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/categories/%E7%AE%97%E6%B3%95%E7%BB%83%E4%B9%A0/">算法练习</a></span></div><div class="content">题目描述
题目链接：96. 不同的二叉搜索树

给你一个整数 n ，求恰由 n 个节点组成且节点值从 1 到 n 互不相同的 二叉搜索树 有多少种？返回满足题意的二叉搜索树的种数。
示例1：

12输入：n = 3输出：5

示例2：
12输入：n = 1输出：1

提示：

1 &lt;= n &lt;= 19

我的题解方法一：动态规划思路选择根节点，则当前树的种数则为左边子树的总数乘以右边子树的种数，即：
12//选择i为根节点，j-1为左边子树的节点个数，i-j为右边子树的节点个数dp[i] = dp[j - 1] * dp[i - j];

代码123456789101112class Solution &#123;    public int numTrees(int n) &#123;        int[] dp = new int[n + 1];        dp[0] = 1;        for (int i = 1; i &lt; dp.length; i++) &#123;            for (int j = 1; j &lt;= i; j+ ...</div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span><a class="page-number" href="/page/2/#content-inner">2</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/#content-inner">6</a><a class="extend next" rel="next" href="/page/2/#content-inner"><i class="fas fa-chevron-right fa-fw"></i></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://geekwolfman-blog.oss-cn-chengdu.aliyuncs.com/config/avatar/avatar.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">狼族少年、血狼</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">57</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">14</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://wpa.qq.com/msgrd?v=3&amp;uin=2370032534&amp;site=qq&amp;menu=yes&amp;jumpflag=1"><i class="fa-brands fa-qq"></i><span>添加博主QQ</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">本站所有博文均是博主的学习笔记与个人理解，来源于网络，如有<span style="color:red;font-weight:bold;">侵权</span>请<a target="_blank" rel="noopener" href="https://wpa.qq.com/msgrd?v=3&uin=2370032534&site=qq&menu=yes&jumpflag=1" style="color:#49B1F5;font-weight:bold">联系我</a>进行删除🥰。</div></div><div class="sticky_layout"><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">57</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2023-03-21T16:00:00.000Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站总字数 :</div><div class="item-count">173k</div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2023-06-08T06:15:23.179Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By 狼族少年、血狼</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"><script>window.typedJSFn = {
  init: (str) => {
    window.typed = new Typed('#subtitle', Object.assign({
      strings: str,
      startDelay: 300,
      typeSpeed: 150,
      loop: true,
      backSpeed: 50,
    }, null))
  },
  run: (subtitleType) => {
    if (true) {
      if (typeof Typed === 'function') {
        subtitleType()
      } else {
        getScript('https://cdn.jsdelivr.net/npm/typed.js/lib/typed.min.js').then(subtitleType)
      }
    } else {
      subtitleType()
    }
  }
}
</script><script>function subtitleType () {
  fetch('https://v1.hitokoto.cn')
    .then(response => response.json())
    .then(data => {
      if (true) {
        const from = '出自 ' + data.from
        const sub = []
        sub.unshift(data.hitokoto, from)
        typedJSFn.init(sub)
      } else {
        document.getElementById('subtitle').innerHTML = data.hitokoto
      }
    })
}
typedJSFn.run(subtitleType)
</script></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="false"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></body></html>